// pages/orderDetail/orderDetail.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isPay: true,
    isUpgrade: false,
    canUpgrade: false,
    upgraded: false,
    isPlus: false,
    price: '59.00',
    upgradeList: [{
      id: 0,
      onthis: true,
      name: '升级套餐一'
    }, {
      id: 1,
      onthis: false,
      name: '升级套餐二'
    }, {
      id: 2,
      onthis: false,
      name: '升级套餐三'
    }],
    receiptRadio: [{
      id: 0,
      checked: true,
      value: 'person',
      name: '个人'
    }, {
      id: 1,
      checked: false,
      value: 'company',
      name: '公司'
    }],
    sexImg: '../../images/male_icon.png',
    sexName: '男士',
    // sexualList: [{
    //   id: 0,
    //   onthis: true,
    //   img: '../../images/male_icon.png',
    //   name: '男士'
    // }, {
    //   id: 1,
    //   onthis: false,
    //   img: '../../images/married_female_icon.png',
    //   name: '女士已婚'
    // }, {
    //   id: 2,
    //   onthis: false,
    //   img: '../../images/single_female_icon.png',
    //   name: '女士未婚'
    // }],
    plusCheckbox: [{

    }, {
      id: 1,
      checked: false,
      value: '222',
      name: '加项包名称2'
    }],
    detailInfoList: [{
      id: 0,
      checked: false,
      value: '111',
      name: '加项包名称1',
      detail: [{
        title: '一般检查A',
        icon: '../../images/married_female_item_icon.png',
        content: '通过仪器测量人体基本健康指标。例如：血压是否正常，有无体重偏低、超重或肥胖。',
        tips: '身高、体重、体重指数、收缩压、舒张压'
      }]
    }, {
      id: 1,
      checked: false,
      value: '222',
      name: '加项包名称2',
      detail: [{
        title: '内科',
        icon: '',
        content: '通过视、触、叩、听体格检查方法，检查心、肺、肝、脾等重要脏器及神经系统基本状况，发现内科常见疾病的重要征兆，或初步排除常见疾病。',
        tips: '病史、家族史、心率、心律、心音、肺部听诊、肝脏触诊、脾脏触诊、肾脏叩诊、神经反射：膝反射、内科其它'
      }, {
        title: '外科',
        icon: '',
        content: '通过体格检查方法，检查男性外科系统（皮肤、甲状腺、骨关节、肛肠、前列腺、外生殖器）等重要脏器基本情况，发现常见外科疾病的重要征兆，或初步排除外科常见疾病。',
        tips: ''
      }]
    }]
  },
  chooseSexual: function(e) {
    let id = e.currentTarget.id,
      list = this.data.sexualList;
    for (let i = 0; i < list.length; i++) {
      list[i].onthis = false;
      if (id == list[i].id) {
        list[i].onthis = true;
      }
    }
    this.setData({
      sexualList: list
    })
  },
  chooseUpgrade: function(e) {
    let id = e.currentTarget.id,
      list = this.data.upgradeList;
    for (let i = 0; i < list.length; i++) {
      list[i].onthis = false;
      if (id == list[i].id) {
        list[i].onthis = true;
      }
    }
    this.setData({
      upgradeList: list
    })
  },
  radioChange: function(e) {
    let items = this.data.receiptRadio;
    for (let i = 0, len = items.length; i < len; ++i) {
      items[i].checked = items[i].value == e.detail.value
    }
    this.setData({
      receiptRadio: items
    });
  },
  checkboxChange: function(e) {
    console.log('checkbox发生change事件，携带value值为：', e.detail.value);
    let list = this.data.detailInfoList,
      id = e.currentTarget.id;
    for (let i = 0; i < list.length; i++) {
      if (id == list[i].id) {
        if (e.detail.value[0] == undefined) {
          list[i].checked = false;
          break;
        }
        list[i].checked = true;
      }
    }
    this.setData({
      detailInfoList: list
    })
  },
  plusShow: function(e) {
    this.setData({
      isPlus: true,
      isUpgrade: false
    })
  },
  levelUpShow: function(e) {
    this.setData({
      isUpgrade: true,
      isPlus: false
    })
  }
})